package v1

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"jwgin/model/mysql"
	"jwgin/service"
)

type resources struct{}

func (l *resources) Routers(Router *gin.RouterGroup) {
	//资源列表
	Router.GET("resources/:classid", l.get) //列表
}
func (l *resources) get(c *gin.Context) {
	id := c.Param("classid")
	if id == "" {
		RespErr(c, fmt.Errorf("参数错误"))
		return
	}

	RoleID := c.GetUint("RoleID")
	if RoleID == 0 {
		RespErr(c, fmt.Errorf("操作失败"))
		return
	}

	list := []map[string]interface{}{}
	service.G.Model(mysql.Resources{}).
		Where("comid = ? AND resources_class_id = ? AND resources_statu = 1", RoleID, id).
		Order("id DESC").Scan(&list)
	RespSucc(c, list)
}
